import {
	BASE_URL
} from './request.js';
 
export const loginRequest = () => {
	return new Promise((resolve, reject) => {
		uni.login({
			provider: 'weixin',
			success: function(loginRes) {	
				console.log(loginRes.code) 
				uni.request({
					url: BASE_URL + '/api/account/v1/oneClick/driverLogin',
					method:'POST',
					data:{
						code :loginRes.code,
					},
					header: {
						"XX-Device-Type": "wxapp", 
						"Content-Type": "application/json",
						"XX-User-Type": 'user',
					},  
					success(res) {
						console.log(res.data.data) 
						uni.setStorageSync('token', res.data.data.token);
						uni.setStorageSync('userData', res.data.data);
						uni.setStorageSync('authStatus', res.data.data.authStatus);
						uni.switchTab({
							url:'/pages/index/index'
						})
					}
				})
			}
		})

	})
}